<?php
namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/5 0005
 * Time: 下午 12:24
 */
class JoinController extends Controller
{
    public function getJoinUs()
    {
        try
        {
            $joins = DB::table('join_us')->get();

            return view('Admin.joinUs')->with('joins', $joins);
        }
        catch (\Exception $exception)
        {

        }
    }

    public function updateJoinUs(Request $request)
    {
        try
        {
            $data = $request->all();
            $id = $data['join_id'];
            $join = [];
            $join['content'] = $data['join_content'];
            $join['email'] = $data['join_email'];

            $result = DB::table('join_us')->where('id', '=', $id)->update($join);
            if ($result)
            {
                return redirect('admin/getJoinUs');
            }
            else
            {
                return json_encode(['code'=>'0','msg'=>'faied']);
            }
        }
        catch (\Exception $exception)
        {
            return json_encode(['code'=>'0','msg'=>'faied', 'status' => 503]);
        }
    }
}